
#include "expandPath.h"
#include "fileExists.h"


#include <iostream>
#include <string>


using namespace std;

int main(){


  cout << "\n\t\t example to test the expandPath and fileExists functions";
  cout << "\n\texpand a path with \"*\" char; check if file is available.\n\n";
  cout << "\n\tthe expandPath returns a vector of strings with the paths, fileExists a boolean value";
  cout << "\n\t\t\t ---------------\n\n";

  //
  // using:  fileExists("./main.cc");
  //    or:  char *fileName="./main.cc"; fileExists( fileName );
  //  works, but generate warning when compiling: 
  //                warning: deprecated conversion from string constant to ‘char*’
  //

  char fileName_1[] = "./main.cc";
  cout << "\n\t Does file \"main.cc\" exist in current dir? " << fileExists( fileName_1 );
  
  char fileName_2[] = "./pippo.pluto";
  cout << "\n\t Does file \"pippo.pluto\" exist in current dir? " << fileExists( fileName_2 );

  cout << "\n\n\n\n\nnow expanding path: \"../../\":";
  string myPath="../../";
  
  vector<string> paths = expandPath( myPath );

  cout << "\n\t found " << paths.size() << " matches:";
  for (size_t i=0; i< paths.size(); i++)
    cout << "\n\t\t found " << i << "\t" << paths[i];
  cout << endl << endl;
  

  cout << "\n\nnow expanding path: \"../include/*dPa*\":";
  paths.clear();

  paths = expandPath( "../include/*dPa*" );

  cout << "\n\t found " << paths.size() << " matches:";
  for (size_t i=0; i< paths.size(); i++)
    cout << "\n\t\t found " << i << "\t"<< paths[i];
  cout << endl << endl;


  cout << "\n\nnow expanding path: \"../..\" with recursion:";
  
  paths.clear();
  paths = expandPath( myPath, true );

  cout << "\n\t found " << paths.size() << " matches:";
  for (size_t i=0; i< paths.size(); i++)
    cout << "\n\t\t found " << i << "\t" << paths[i];
  cout << endl << endl;


    cout << "\n\nnow expanding path: \"../..\" with recursion, looking for \"*.h\" files:";

  paths.clear();
  paths = expandPath( myPath, true, ".h" );

  cout << "\n\t found " << paths.size() << " matches:";
  for (size_t i=0; i< paths.size(); i++)
    cout << "\n\t\t found " << i << "\t" << paths[i];
  cout << endl << endl;

  cout << "\n\nnow expanding wrong path: \"/pippoANDpluto/\" with recursion:";
  paths.clear();
  paths = expandPath( "/pippoANDpluto/", true, "" );

  cout << "\n\t found " << paths.size() << " matches:";
  for (size_t i=0; i< paths.size(); i++)
    cout << "\n\t\t found " << i << "\t" << paths[i];
  cout << endl << endl;


  return 0;
}

